package org.huntaway.ant.tools;

import java.io.File;
import java.net.URL;

import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.Copy;
import org.apache.tools.ant.taskdefs.Exec;
import org.apache.tools.ant.taskdefs.Get;
import org.apache.tools.ant.taskdefs.Move;
import org.apache.tools.ant.taskdefs.Tar;
import org.apache.tools.ant.taskdefs.Zip;

public class AntUtil {
	public static void fileCopy(File srcFile, File destFile) {
		Project prj = new Project();
		Copy copy = new Copy();
		copy.setProject(prj);
		copy.setFile(srcFile);
		copy.setTodir(destFile);
		copy.execute();
	}

	public static void fileMove(File srcFile, File destFile) {
		Project prj = new Project();
		Move move = new Move();
		move.setProject(prj);
		move.setFile(srcFile);
		move.setTodir(destFile);
		move.execute();
	}
	public static void get(URL url, File destFile) {
		Project prj = new Project();
		Get get = new Get();
		get.setSrc(url);	
		get.setDest(destFile);
		get.setProject(prj);
		get.execute();
	}	
	public static void tar() {
		Project prj = new Project();
		Tar tar = new Tar();
		tar.setExcludes("target/**");
		tar.setBasedir(new File("E:/jskyme/code/company/ksdfront/trunk/ksdfront"));
		tar.setDestFile(new File("E:/ksdfront.tar"));	
		tar.setProject(prj);
		tar.execute();
	}	
	public static void zip() {
		Project prj = new Project();
		Zip tar = new Zip();
		tar.setExcludes("target/**");
		tar.setBasedir(new File("E:/jskyme/code/company/ksdfront/trunk/ksdfront"));
		tar.setDestFile(new File("E:/ksdfront.zip"));	
		tar.setProject(prj);
		tar.execute();
	}	
}
